package com.qianclass.talklive.app.view;

import android.content.Context;
import android.graphics.Rect;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewDebug;
import android.widget.TextView;

/**
 * Created by Administrator on 2017/11/15.
 */

public class LongTextView extends TextView {
    public LongTextView(Context context) {
        this(context, null);
    }

    public LongTextView(Context context, AttributeSet attrs) {
        super(context, attrs);

        //单行显示
        setSingleLine();

        setFocusable(true);

        setFocusableInTouchMode(true);

        setEllipsize(TextUtils.TruncateAt.MARQUEE);
    }

    @Override
    @ViewDebug.ExportedProperty(category = "focus")
    public boolean isFocused() {
        //一直获取焦点
        return true;
    }

    @Override
    protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
        if (focused) {
            super.onFocusChanged(focused, direction, previouslyFocusedRect);
        }
    }

    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
        if (hasWindowFocus) {
            super.onWindowFocusChanged(hasWindowFocus);
        }
    }
}
